import os
from os.path import getsize, join


def getdirsize(dir):
    size = 0
    for root, dirs, files in os.walk(dir):
        size += sum([getsize(join(root, name)) for name in files])
    return size


directorySize = getdirsize('D:\vmwares')
print('There are %.3f' % (directorySize / 1024 / 1024), 'Mbytes ')
